package org.devops  
  
class DockerfileTemplate {  
    static String Generate(String SERVICE_NAME, String INIT_JAVA_FILE, String BASE_IMAGE) {  
        return """  
        FROM ${BASE_IMAGE}
        
        LABEL maintainer="hezw <hezw1025v@163.com>"
        
        RUN groupadd app -g 2022 && useradd app -u 2022 -g 2022
        RUN mkdir -p /app/server/${SERVICE_NAME}/
        
        ADD ${INIT_JAVA_FILE} /app/server/${SERVICE_NAME}/${SERVICE_NAME}.jar
        ADD run.sh        /app/server/${SERVICE_NAME}/
        
        RUN chown -R app:app    /app
        RUN chmod -R 755        /app
        
        WORKDIR  /app/server/${SERVICE_NAME}/
        USER app
        
        ENTRYPOINT ["/app/server/${SERVICE_NAME}/run.sh"]
        """.stripIndent()  
    }  
}
